<template>
    <h2>添加页面</h2>
    <table>
        <tr>
            <td>姓名</td>
            <td>
                <input type="text" v-model="info.name"/>
            </td>
        </tr>
        <tr>
            <td>密码</td>
            <td>
                <input type="text" v-model="info.pwd"/>
            </td>
        </tr>
        <tr>
            <td>年龄</td>
            <td>
                <input type="text" v-model="info.age"/>
            </td>
        </tr>
        <tr>
            <td>性别</td>
            <td>
                <input type="radio" value="男" v-model="info.sex"/>男
                <input type="radio" value="女" v-model="info.sex"/>女
            </td>
        </tr>
        <tr>
            <td>手机号</td>
            <td>
                <input type="text" v-model="info.phone"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="保存" @click="add"/>
            </td>
        </tr>
    </table>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';
const info=ref({
    "id": 0,
  "name": "",
  "pwd": "",
  "sex": "",
  "phone": " ",
  "age": 0
})
const add=()=>{
    axios.post("https://localhost:7237/api/user/ueradd",info.value).then(res=>{
        if(res.data==-1){
            alert('姓名重复了');
        }
        else if(res.data>0){
            alert('成功');
        }
        else{
            alert('失败');
        }
    })
}
</script>

